<div class="layuimini-main">

	<div class="layui-form layuimini-form">
		<div class="layui-form-item">
			<label class="layui-form-label required">用户名</label>
			<div class="layui-input-block">
				<input type="text" name="user_name" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入用户名" value="" class="layui-input">
				<tip>填写自己管理账号的名称。</tip>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">昵称</label>
			<div class="layui-input-block">
				<input type="text" name="real_name" lay-verify="required" lay-reqtext="昵称不能为空" placeholder="请输入昵称" value="" class="layui-input">
				<tip>填写自己管理账号的名称。</tip>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">手机</label>
			<div class="layui-input-block">
				<input type="number" name="phone" lay-verify="required|phone" lay-reqtext="手机不能为空" placeholder="请输入手机" value=""
				 class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">密码</label>
			<div class="layui-input-block">
				<input type="password" name="password" lay-verify="required" placeholder="请输入密码" value="" class="layui-input">
			</div>
		</div>
		
		<div class="layui-form-item">
			<label class="layui-form-label">角色</label>
			<div class="layui-input-block">
				<!-- <select id="role_select" name="role_pid" class="xm-select-demo" lay-verify="required" lay-search="">
				</select> -->
				<div id ="role_select"></div>
			</div>
		</div>
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">备注信息</label>
			<div class="layui-input-block">
				<textarea name="remark" class="layui-textarea" placeholder="请输入备注信息"></textarea>
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
			</div>
		</div>
	</div>
</div>
<script>
	layui.use(['form', 'table', 'hsw'], function() {
		var form = layui.form,
			layer = layui.layer,
			table = layui.table,
			hsw = layui.hsw,
			$ = layui.$;


		
	
		/* 初始化select*/
		hsw.hsw_post(HSW_API_MANAGE_ROLE_SELECT, {}, function(data) {
		
			hsw.hsw_double_select("role_select","role_pid","请选择角色",data);
			
			form.render();
		});

		
		// 当前弹出层，防止ID被覆盖
		var parentIndex = layer.index;

		//监听提交
		form.on('submit(saveBtn)', function(data) {
			hsw.hsw_post(HSW_API_MANAGE_USER_ADD, data.field, function(data) {
					//console.log(data);

					layer.msg('操作成功，即将刷新页面', {
						time: 3000 //
					}, function() {
						hsw.hsw_html_reload(0);
					});

					// 关闭弹出层
					layer.close(index);
					layer.close(parentIndex);

			});
			return false;
		});

	});
</script>
